<script type="text/javascript">

    

    $(function() {
        $("a").button();
        window.onclose=function() {
            logout();
        }
    });

    //window.setTimeout("checkWaitingPatient()", 3000);
    var timeout = 3000;//Save Time Interval
    var timer;

    $(document).ready(function() {
        timer = $.timer(timeout, function() {
            checkWaitingPatient();
        });
    });

    function logout(){
        $.ajax({
            type: "POST",
            url: "../doctor/logout",
            data: {
            },
            dataType: "html",
            success: function(data) {               
            }
        });
    }

    function checkWaitingPatient(){
        
        $.ajax({
            type: "POST",
            url: "../ajax/checkWaitingPatient/",
            data: {               
            },
            dataType: "html",
            success: function(data) {              
               $('#div_waiting').html(data);
            }
        });
    }

    
</script>
<div style="width: 100%;height: 100%;overflow: hidden;background-color: #222222" align="center">
    <div style="width: 80%;height: 98%;background-color: #eeeeee;overflow: auto;margin-top: 5px;border: 1px solid silver" align="center" class="ui-widget ui-corner-all">
        <table width="100%">
            <tr><td align="right">
                    <a id="edit" href="<?php echo url::base()?>/doctor/edit">แก้ไขข้อมูลส่วนตัว</a>
                    <a id="logout" href="<?php echo url::base()?>/doctor/logout">ออกจากระบบ</a></td></tr>
        </table>
        <table width="100%" cellspacing="0">
            <tr><td width="250" align="center" valign="top">
                    <table class="ui-widget ui-widget-content ui-corner-all" style="height: 400px" cellspacing="0">
                        <tr class="ui-widget-header"><td height="20">คนไข้ที่กำลังรอการตรวจ</td></tr>
                        <tr><td valign="top"><table width="100%">
                        <div id="div_waiting">
                        
                        </div>
                        </table>
                        </td></tr>
                        <tr><td>&nbsp;</td></tr>
                    </table>
                </td>
                <td valign="top">
                    <table class="ui-widget ui-widget-content ui-corner-all" width="99%" cellpadding="3" cellspacing="0" style="font-size: 16px">
                        <tr class="ui-widget-header"><td width="120">คนไข้</td><td>คุณหมอเจ้าของไข้</td><td>สถานที่ทำการตรวจ</td><td>วันเวลาที่เริ่มตรวจ</td><td>วันเวลาที่ตรวจเสร็จ</td><td></td></tr>
       <?php
       if($histories!=null){
           foreach($histories as $history) {
             echo  "<tr>
                    <td align=left>".$history['p_fname']."</td>
                    <td align=left>".$history['doctor_name']."</td>
                    <td align=left>".$history['pp_name']."</td>
                    <td align=left>".$history['consult_start']."</td>
                    <td align=left>".$history['consult_end']."</td>
                    <td align=left><a target='_blank' href='".URL::base()."patient/history?c_id=".$history['c_id']."&p_id=".$history['p_id']."' target=''>". html::image('assets/icon/paper_content_48.png',array('width' => '24', 'height' => '24','border'=>'0'))."</a></td>
               </tr>";
            }
       }else{
           echo "<tr><td colspan=7 align=center>ยังไม่มีประวัติการตรวจ</td></tr>";
       }
       ?>       
                    </table>
                </td></tr>
        </table>


    </div>
    <div style="width: 80%;height: 50px;
         padding: 0;
         border: 1px solid rgba(0,0,0,0.5);
         border-radius: 2px 2px 10px 10px;
         background: rgba(0,0,0,0.25);
         box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
         -o-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
         -webkit-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
         -moz-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);"></div>
</div>